package com.zhyonk.controller;

import com.zhyonk.domain.School;
import com.zhyonk.mapper.SchoolMapper;
import com.zhyonk.util.ImageBase64Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cbl
 * @description com.zhyonk.controller
 * @date 2020/7/11
 * 基本测试类功能
 */
@RestController
public class TestController {

    @Autowired
    private SchoolMapper schoolMapper;

    @PostMapping("/test")
    public void test() {
//        School ssss = new School();
        List<School> schoolList = schoolMapper.selectList(null);
        for (School s : schoolList) {
            //School s = schoolList.get(0);
            String httpImg = s.getImg();
            String base64 = ImageBase64Utils.NetImageToBase64(httpImg);
            School school = new School();
//            s.setImgbase64(base64);
            int i = schoolMapper.updateById(s);
            System.out.println("####" + i);
        }

    }


    /*public static void main(String[] args) throws IOException {
        List<School> schoolList = schoolMapper.selectList(null);
        //for (School s : schoolList) {
        School s = schoolList.get(0);
        String httpImg = s.getImg();
        String base64 = ImageBase64Utils.NetImageToBase64(httpImg);
        School school = new School();
        school.setScId(s.getScId());
        school.setImgbase64(base64);
        int i = schoolMapper.updateById(school);
        System.out.println("####" + i);
        //}
    }
*/
}
